#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

const int kMaxM = 1010;
const int kInf = 1e9;

int cnt[kMaxM], sum[kMaxM];
int f[kMaxM][2];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, x, y;

  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++) {
    string s;

    cin >> s;
    for (int j = 0; j < m; j++) {
      cnt[j + 1] += (s[j] == '#');
    }
  }
  for (int j = 1; j <= m; j++) {
    sum[j] = sum[j - 1] + cnt[j];
    f[j][0] = f[j][1] = 1e9;
  }
  f[0][0] = f[0][1] = 0;
  for (int i = x; i <= m; i++) {
    for (int j = i - x; j >= i - y && j >= 0; j--) {
      f[i][0] = min(f[i][0], f[j][1] + sum[i] - sum[j]);
      f[i][1] = min(f[i][1], f[j][0] + n * (i - j) - (sum[i] - sum[j]));
    }
  }
  cout << min(f[m][0], f[m][1]) << "\n";
  return 0;
}